
// 运营管理
import {
  request,
  METHOD
} from '@/utils/request'

import axios from 'axios'

import Cookie from 'js-cookie'
const BASE_URL = process.env.VUE_APP_API_URL

// 出库单首页管理列表查询 （适用admin和小程序）
export async function BoundList (params) {
  return request(`${BASE_URL}/business/admin/bound/list`, METHOD.GET, params)
}
// 新建banner
export async function createBanner (data) {
  return request(`${BASE_URL}/business/admin/banners`, METHOD.POST, data)
}
// banner详情
export async function searchBanner (id) {
  return request(`${BASE_URL}/business/admin/banners/${id}`, METHOD.GET)
}

// 修改banner
export async function editBanner (data, id) {
  return request(`${BASE_URL}/business/admin/banners/${id}`, METHOD.PUT, data)
}
// 新增优惠券
export async function addCoupon (params) {
  return request(`${BASE_URL}/promotion/admin/couponPromotions`, METHOD.POST, params)
}
// 查看优惠券（回显）
export async function searchCoupon (id) {
  return request(`${BASE_URL}/promotion/admin/couponPromotions/${id}`, METHOD.GET)
}

// 修改优惠券
export async function editCoupon (data, id) {
  return request(`${BASE_URL}/promotion/admin/couponPromotions/${id}`, METHOD.PUT, data)
}
// 审核详情
export async function auditListGet (id) {
  return request(`${BASE_URL}/business/admin/vehicleLock/audit/detail/${id}`, METHOD.GET)
}
// 锁定审核
export async function auditListEdit (params) {
  return request(`${BASE_URL}/business/admin/vehicleLock/audit`, METHOD.POST, params)
}
// 品牌图片上传
export function uploadLogoLogo () {
  return `${BASE_URL}/business/admin/brands/uploadLogo`
}
// 品牌新增
export async function brandAdd (params) {
  return request(`${BASE_URL}/business/admin/brands`, METHOD.POST, params)
}
// 新增渠道表
export async function channelInfoAdd (params) {
  return request(`${BASE_URL}/order/admin/channelInfo`, METHOD.POST, params)
}
// 运营管理-设备型号库-新增设备型号
export async function deviceModelInfoAdd (params) {
  return request(`${BASE_URL}/business/admin/deviceModelInfo`, METHOD.POST, params)
}

// 品牌编辑
export async function brandEdit (id, params) {
  return request(`${BASE_URL}/business/admin/brands/${id}`, METHOD.PUT, params)
}
// 修改渠道表
export async function channelInfoEdit (id, params) {
  return request(`${BASE_URL}/order/admin/channelInfo/${id}`, METHOD.PUT, params)
}
// 品牌新增
export async function brandGet (id) {
  return request(`${BASE_URL}/business/admin/brands/${id}`, METHOD.GET)
}
// 优惠券详情
export async function couponPromotionsDetail (id) {
  return request(`${BASE_URL}/promotion/admin/couponPromotions/${id}`, METHOD.GET)
}
// 租车可用优惠券list
export async function couponsList (id, params) {
  return request(`${BASE_URL}/promotion/admin/coupons`, METHOD.GET, { ...params, couponPromotionId: id })
}
// 已领取优惠券分页查询
export async function sentCouponsList (id, params) {
  return request(`${BASE_URL}/promotion/admin/couponPromotions/${id}/sentCoupons`, METHOD.GET, params)
}
// 图片上传
export function uploadBanner () {
  return `${BASE_URL}/business/admin/banners/uploadImage`
}

// 查看兑换码
export async function fetchAllByGeneratedLog (params) {
  return request(`${BASE_URL}/promotion/admin/coupons/fetchAllByGeneratedLog`, METHOD.GET, params)
}

// 生成记录
export async function generatedLogs (params) {
  return request(`${BASE_URL}/promotion/admin/couponPromotions/generatedLogs`, METHOD.GET, params)
}

// 生成兑换码
export async function generateCoupons (params) {
  return request(`${BASE_URL}/promotion/admin/couponPromotions/generateCoupons`, METHOD.POST, params)
}

// 优惠券生成记录导出
export const exportGeneratedCoupons = (params) => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    timeout: 60 * 1000,
    url: `${BASE_URL}/promotion/admin/coupons/exportGeneratedCoupons`,
    responseType: 'blob',
    params
  })
}
// 车辆管理-中控设备-设备管理-批量操作-验证
export async function verifySomeDecviceNo (params) {
  return request(`${BASE_URL}/business/admin/deviceInfo/batchOperateCheck`, METHOD.POST, params)
}
// 车辆管理-中控设备-设备管理-批量操作
export async function operateSomeDecviceNo (params) {
  return request(`${BASE_URL}/business/admin/deviceInfo/batchOperate`, METHOD.POST, params)
}
// 车辆管理-中控设备-设备管理-导出
export const deviceExport = (params) => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    timeout: 60 * 1000,
    url: `${BASE_URL}/business/admin/deviceInfo/export`,
    responseType: 'blob',
    params
  })
}

// 车辆-出库管理-列表-导出 WYJ
export const boundListExport = (params) => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    timeout: 60 * 1000,
    url: `${BASE_URL}/business/admin/bound/export`,
    responseType: 'blob',
    params
  })
}
